package com.unionpay.upyzt.model;

import com.unionpay.upyzt.exception.UpyztException;
import com.unionpay.upyzt.net.APIResource;
import com.unionpay.upyzt.resp.TransferRefundResp;
import java.util.Map;
import lombok.experimental.Accessors;

/**
 * 转账入金退款
 */
@Accessors(chain = true)
public class TransferRefund extends APIResource {

    /**
     * 转账入金退款
     *
     * @param params 请求参数
     * @return 返回结果
     * @throws UpyztException 异常
     */
    public static TransferRefundResp refunds(Map<String, Object> params) throws UpyztException {
        return APIResource
            .request(RequestMethod.POST,
                classURL(TransferRefund.class), params,
                TransferRefundResp.class, null);
    }

    /**
     * 退款订单查询（系统订单号）
     *
     * @param transferRefundId 系统订单号
     * @return 返回结果
     * @throws UpyztException 异常
     */
    public static TransferRefundResp retrieveById(String transferRefundId) throws UpyztException {
        return APIResource
            .request(RequestMethod.GET,
                instanceURL(TransferRefund.class, transferRefundId), null,
                TransferRefundResp.class, null);
    }

    /**
     * 退款订单查询（平台订单号）
     *
     * @param outOrderNo 平台订单号
     * @return 返回结果
     * @throws UpyztException 异常
     */
    public static TransferRefundResp retrieveByOutOrderNo(String outOrderNo) throws UpyztException {
        return APIResource
            .request(APIResource.RequestMethod.GET,
                instanceURL(TransferRefund.class, "_by_out_order_no", outOrderNo), null,
                TransferRefundResp.class, null);
    }
}
